/** Score, ACM/ICPC Seoul 2005, UVa1585 */
#include<bits/stdc++.h>
using namespace std;
int main() {
#ifdef DEBUG
  freopen("in.txt","r",stdin);
  freopen("out.txt","w",stdout);
#endif
  char ch;
  int bns=0, sum=0;
  int T;
  scanf("%d\n", &T);
  while(T--) {
    sum = 0;
    bns = 0;
    while(scanf("%c", &ch)==1) {
      if(ch=='O') {
        bns += 1;
        sum += bns;
      }
      else if(ch=='X') {
        bns = 0;
      }
      else if(ch=='\n') break;
    }
    cout << sum << endl;
  }
  return 0;
}
